// by Jens Schmidt 2009
// for: YOU
// use, modify, copy this as you like

var Settings = Class.create({
	initialize: function() {
		this.settingsCookieName = new Mojo.Model.Cookie(Settings.kCookieName);
		this.settingsCookiePass = new Mojo.Model.Cookie(Settings.kCookiePass);
		

		this.Name = "";
		this.Pass = "";

		this.settingsLoad();
	},

	// loads settings from a cookie.
	settingsLoad: function() {
		if (this.settingsCookieName) {
			this.Name = this.settingsCookieName.get();
		}
		

		if (this.settingsCookiePass) {
			this.Pass = this.settingsCookiePass.get();
		}
	},

	loginSet: function(userName, password) {
		if (this.settingsCookieName && userName) {
			this.settingsCookieName.put(userName);
			this.Name = userName;
		} else {
			this.Name = "";
			this.settingsCookieName.put(userName)
		}

		if (this.settingsCookiePass && password && password.length>0){
			if (this.Pass !== password) {
				this.Pass = Md5.MD5(password);
				this.settingsCookiePass.put(this.Pass);
			}
		}else{
			this.Pass = "";
			this.settingsCookiePass.put(this.Pass);
		}
	}
});

Settings.kCookieName = "usernamename";
Settings.kCookiePass = "password";
